package algorithm.easy;

import java.util.ArrayList;
import java.util.List;

public class Solution119 {

    //输入: rowIndex = 3
    //输出: [1,3,3,1]
    public static List<Integer> getRow(int rowIndex) {
        List<Integer> list = new ArrayList<>();
        if(rowIndex < 0){
            return null;
        }else if(rowIndex ==0){
            Integer integer = new Integer(1);
            list.add(integer);
            return list;
        } else {
            List<Integer>  listTemp = getRow(rowIndex-1);
            for(int i=0;i<listTemp.size();i++){
                if(i==0){
                    list.add(new Integer(1));
                }
                else if(i!=0){
                    Integer integer = listTemp.get(i)+listTemp.get(i-1);
                    list.add(integer);
                }
            }
            list.add(new Integer(1));
        }
        return list;
    }
    public static void main(String[] args){
        int rowIndex =3;
        System.out.println(getRow(rowIndex));
    }
}
